#include "StdAfx.h"
#include "KeyManifest.h"
#include "ObjectFactory.h"

KeyManifest::KeyManifest(void)
{
	_engine = newAESEngine();
}

KeyManifest::~KeyManifest(void)
{
}

bool KeyManifest::validateState()
{
	bool result = true;

	if (!_engine){
		perror ("validateState: E_INVALID_STATE");

		return false;
	}	

	return result;
}


int KeyManifest::getEngine(IAESEngine **engine)
{
	int result = E_SUCCESS;

	// params sanity check
	if (!engine){
		perror ("getEngine: E_INVALID_ARG");

		return E_INVALID_ARGS;
	}

	// internal state check
	if (!validateState()){
		return E_INVALID_STATE;
	}

	// return the engine object
	*engine = _engine;

	return result;
}

int KeyManifest::getKey(const char* keyLabel, IAESKey **key)
{
	int result = E_SUCCESS;

	if (!keyLabel || !key){
		perror ("getKey: E_INVALID_ARG");

		return E_INVALID_ARGS;
	}

	*key = (IAESKey*) newKey(this, keyLabel);

	return result;
}